package cn.liumouren.tool.pad.controller;


import cn.liumouren.tool.pac.ApiUtil;
import cn.liumouren.tool.pac.entity.*;
import cn.liumouren.tool.pad.service.WindowService;
import cn.liumouren.tool.security.autoconfigure.annotation.RequirePermissions;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 窗口(Window)表控制层
 *
 * @author daniel liu
 */
@RestController
@RequestMapping("/window")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class WindowController {

    private final WindowService windowService;

    /**
     * 全能
     */
    @PostMapping("/api")
    @RequirePermissions("user")
    public PageResult api(@RequestBody Execution execution) {
        return ApiUtil.execute(windowService, execution);
    }

    // =============================================================
    // 如果想要体现出restful的风格, 可使用下面的方式
    // =============================================================

    /**
     * query
     */
    @PostMapping("/query")
    public PageResult query(@RequestBody Query query) {
        return ApiUtil.execute(windowService, query);
    }

    /**
     * update
     */
    @PutMapping("/update")
    public PageResult update(@RequestBody Update update) {
        return ApiUtil.execute(windowService, update);
    }

    /**
     * delete
     */
    @DeleteMapping("/delete")
    public PageResult delete(@RequestBody Delete delete) {
        return ApiUtil.execute(windowService, delete);
    }

    /**
     * insert
     */
    @PostMapping("/insert")
    public PageResult insert(@RequestBody Insert insert) {
        return ApiUtil.execute(windowService, insert);
    }


}